<template>
	<div class="auditor-main">
		<!-- 代理人 -->
		<!-- <div v-if="roleID == 2"> -->
			<div>
				<orderStatistics :myInfo ='myInfo' :roleID='roleID'  @getData='getData'/>
				<!-- v-if='$store.state.user.vip == 0' -->
				<el-button type="primary" @click='lastMonthSettlement' >上月结算明细</el-button>
				<el-popover placement="left" trigger="click">
					<template>
						<el-checkbox v-model="checked" @change="selectAll">全选</el-checkbox>
						<br />
						<el-checkbox v-model="checked1">订单编号</el-checkbox>
						<br />
						<el-checkbox v-model="checked2">专利类型</el-checkbox>
						<br />
						<el-checkbox v-model="checked10">案件名称</el-checkbox>
						<br />
						<el-checkbox v-model="checked11">联络人</el-checkbox>
						<br />
						<el-checkbox v-model="checked3">扣款情况</el-checkbox>
						<br />
						<el-checkbox v-model="checked4">案件奖励</el-checkbox>
						<br />
						<el-checkbox v-model="checked6">结算金额</el-checkbox>
						<br />
						<el-checkbox v-model="checked8">实际金额</el-checkbox>
						<br />
						<el-checkbox v-model="checked5">结算状态</el-checkbox>
						<br />
						<el-checkbox v-model="checked7">结算类型</el-checkbox>
						<br />
						<!-- <el-checkbox v-model="checked9">修改时间</el-checkbox>
						<br /> -->
						<el-checkbox v-model="checked12">定稿时间</el-checkbox>
					</template>
					<el-button style="float: right;margin-bottom: 5px;margin-top: 0;" slot="reference" icon="el-icon-arrow-down">显示字段</el-button>
				</el-popover>

				<!-- 列表查找 -->
				<span class="down-execel">
					<!-- <Icon type="ios-funnel-outline" /><a href="javascript:;">筛选条件</a> -->
					<Poptip v-model="showFilter" placement="bottom-end">
						<!-- <Icon type="ios-funnel-outline" /> -->
						<i class="el-icon-search poptip-condition-add"></i>
						<a href="javascript:;"  class='poptip-condition-add'>列表查找</a>
						<!-- <div slot="title"><i></i></div> -->
						<div slot="content">
							<Poptip v-model="showFilterCondition" placement="bottom-start" class='poptip-condition'>
								<i class="el-icon-plus"></i>
								<a href="javascript:;">添加过滤条件</a>

								<div slot="content" class="condition-list">
									<ul>
										<li v-for="(item, index) in columns" :key='index' class = 'poptip-condition-item' @click="addFilterCondition(item)">{{item.label}}</li>
									</ul>
								</div>
							</Poptip>

							<el-form :model="conditionForm" ref="conditionForm" label-min-width="120px" class="demo-dynamic" @submit.native.prevent>
								<el-form-item
										v-for="(condition, index) in conditionForm.condition"
										:label="condition.label"
										:key="condition.key"
										:prop="'condition.' + index + '.value'"
										:rules="{
											required: true, message: condition.label + '不能为空', trigger: 'blur'
										}"
									>


									<el-select v-if='condition.label === "流程状态"' v-model="condition.value" placeholder="流程状态" size="small">
										<el-option label="等待提交国知局" value="等待提交国知局"></el-option>
										<el-option label="已提交国知局" value="已提交国知局"></el-option>
										<el-option label="等待答复" value="等待答复"></el-option>
										<el-option label="等待补正" value="等待补正"></el-option>
										<el-option label="已答复" value="已答复"></el-option>
										<el-option label="已补正" value="已补正"></el-option>
										<el-option label="受理" value="受理"></el-option>
										<el-option label="初步审查合格" value="初步审查合格"></el-option>
										<el-option label="实质审查中" value="实质审查中"></el-option>
										<el-option label="驳回" value="驳回"></el-option>
										<el-option label="授权" value="授权"></el-option>
										<el-option label="撤案" value="撤案"></el-option>
									</el-select>

									<el-select v-else-if='condition.label === "专利类型"' v-model="condition.value" placeholder="请选择专利类型" size="small">
										<el-option label="发明专利" value="F"></el-option>
										<el-option label="实用新型" value="S"></el-option>
										<el-option label="外观设计" value="W"></el-option>
										<!-- <el-option label="不确定" value="不确定"></el-option> -->
									</el-select>

									<el-select v-else-if='condition.label === "结算状态"' v-model="condition.value" placeholder="请选择结算状态" size="small">
										<el-option label="已结算" value="1"></el-option>
										<el-option label="未结算" value="2"></el-option>
									</el-select>

									<el-date-picker
										v-model="upDateTime"
										type="daterange"
										placeholder="选择日期"
										value-format="yyyy-MM-dd"
										:validate-event='false'
										@input = 'changInput'
										size="small"
										v-else-if='condition.label === "修改时间"'>
									</el-date-picker>
									<el-date-picker
										v-model="createdTime"
										type="daterange"
										placeholder="选择日期"
										value-format="yyyy-MM-dd"
										:validate-event='false'
										@input = 'changInput'
										size="small"
										v-else-if='condition.label === "定稿时间"'>
									</el-date-picker>

									<el-input v-else size="small" v-model="condition.value" @keyup.enter.native="submitsearch('conditionForm')"></el-input>
									<el-button @click.stop="removeDomain(condition)" size="mini">删除</el-button>
								</el-form-item>
							</el-form>

							<div class="btns">
								<el-button @click="submitsearch('conditionForm')" size="mini">查询</el-button>
								<el-button  @click="resetForm('conditionForm')" size="mini">重置</el-button>
							</div>
						</div>
					</Poptip>
				</span>
			</div>

			<el-table
				ref="orderTb"
				:data="tableData"
				border
				style="width: 100%"
				v-loading="loading"
				class="end_table"
				height="88%"
				show-summary
				:summary-method="getSummaries"
				@sort-change='tableSortChange'
			  @row-click="setttlementDetail">
				<el-table-column show-overflow-tooltip prop="id" label="ID" min-width="60" align="left" v-if='checked99'>
					<template slot-scope="scope">{{(scope.$index+1)+(currentPage-1)*tableSize}}</template>
				</el-table-column>
				<el-table-column show-overflow-tooltip v-if="checked1" prop="order_number" label="订单编号" min-width="180" align="left" sortable='custom'>
					<template slot-scope="scope">
						<span v-if='scope.row.final'>
							{{ scope.row.final.order_number | getNullVal }}
						</span>
						<span v-else>
							无
						</span>
					</template>
				</el-table-column>
				<el-table-column show-overflow-tooltip v-if="checked2" prop="type" label="专利类型" min-width="120" align="left" sortable='custom'>
					<template slot-scope="scope">
						<span v-if='scope.row.final'>
							{{ scope.row.final.type | typeFilter }}
						</span>
						<span v-else>
							无
						</span>
					</template>
				</el-table-column>
				<el-table-column show-overflow-tooltip v-if="checked10" prop="name" label="案件名称" min-width="150" align="left" sortable='custom'>
					<template slot-scope="scope">
						<!-- {{scope.row.final.name | getNullVal}} -->
						<span v-if='scope.row.final'>
							{{ scope.row.final.name | getNullVal }}
						</span>
						<span v-else>
							无
						</span>
					</template>
				</el-table-column>
				<el-table-column show-overflow-tooltip v-if="checked11" prop='liaisons' label="联络人" min-width="120" align="left" sortable='custom'>
					<template slot-scope="scope">
						<span v-if='scope.row.final'>
							<template v-if='scope.row.final.order'>
								{{ scope.row.final.order.liaisons | getNullVal }}
							</template>
							<template v-else>
								无
							</template>
						</span>
						<span v-else>
							无
						</span>
					</template>
				</el-table-column>
				<el-table-column show-overflow-tooltip v-if="checked3" prop='deduction' label="扣款情况" min-width="140" align="left" sortable='custom' class-name="font_danger">
					<template slot="header">
						<span class="font_grayness">扣款情况(元)</span>
					</template>
					<template slot-scope="scope">
						<span :class=" Number(scope.row.deduction) != 0 ? 'font_danger' : 'font_black'">{{ scope.row.deduction }}</span>
					</template>
				</el-table-column>
				<el-table-column show-overflow-tooltip v-if="checked4" prop='reward' label="案件奖励" min-width="140" align="left" sortable='custom' class-name="font_success">
					<template slot="header">
						<span class="font_grayness">案件奖励(元)</span>
					</template>
					<template slot-scope="scope">
						<span :class=" Number(scope.row.reward) != 0 ? 'font_success' : 'font_black'">{{ scope.row.reward }}</span>
					</template>
				</el-table-column>
				<el-table-column show-overflow-tooltip v-if="checked6" prop='settlements_price' label="结算金额" min-width="140" align="left" sortable='custom' class-name="font_warning">
					<template slot="header">
						<span class="font_grayness">结算金额(元)</span>
					</template>
					<template slot-scope="scope">
						<span :class=" Number(scope.row.prices) != 0 ? 'font_warning' : 'font_black'">{{ scope.row.prices }}</span>
					</template>
				</el-table-column>
				<el-table-column show-overflow-tooltip v-if="checked8" prop='actual_amount' label="实际金额" sortable='custom' min-width="140" align="left" class-name="font_success">
					<template slot="header">
						<span class="font_grayness">实际金额(元)</span>
					</template>
					<template slot-scope="scope">
						<span :class=" Number(scope.row.actual_amount) > 0 ? 'font_success' : 'font_danger'">{{ scope.row.actual_amount }}</span>
					</template>
				</el-table-column>
				<!-- <el-table-column show-overflow-tooltip v-if="checked4" prop='chargeType' label="扣款类型" min-width="120" align="left" >
					<template slot-scope="scope">
						{{scope.row.chargeType | getNullVal}}
					</template>
				</el-table-column> -->

				<el-table-column show-overflow-tooltip v-if="checked5" prop='status' label="结算状态" min-width="120" align="left" sortable='custom'>
					<template slot-scope="scope">
						{{scope.row.status == 1 ? '已结算' : '未结算' | getNullVal}}
					</template>
				</el-table-column>

				<el-table-column show-overflow-tooltip v-if="checked7" prop='settlements_name' label="结算类型" min-width="120" align="left" sortable='custom' >
					<template slot-scope="scope">
						<template v-if="scope.row.settlements_name == '导入结算'"> {{ scope.row.settlements_name}}</template>
						<template v-else>
							{{ scope.row.settlements_name | getNullVal }}
						</template>
					</template>
				</el-table-column>

				<!-- <el-table-column show-overflow-tooltip v-if="checked9" prop="updated_at" label="修改时间" min-width="180" align="left" sortable='custom'>
					<template slot-scope="scope">
						{{scope.row.updated_at | getNullVal}}
					</template>
				</el-table-column> -->
				<el-table-column show-overflow-tooltip v-if="checked12" prop="created_at" label="定稿时间" min-width="180" align="left" sortable='custom'>
					<template slot-scope="scope">
						{{scope.row.created_at | getNullVal}}
					</template>
				</el-table-column>
			</el-table>
		<!-- </div> -->
		<el-pagination class="pagination" @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
			:page-sizes="pageSizes" :page-size="Number(pageSize)" layout="total, sizes, prev, pager, next, jumper" :total="total"></el-pagination>
		<!-- 查看 -->
		<lookDialog :order_process="order_process" :order_agent="order_agent" ref="orderDialog" @chageData="search"></lookDialog>
		<settlement-detail ref="settlement-detail" @refresh="search"></settlement-detail>
		<!-- <settlementDetail2 ref="settlementDetail2" @refresh="search"></settlementDetail2> -->
		<lastMonthSettlement ref='lastMonthSettlement'></lastMonthSettlement>
	</div>
</template>


<script>
	import lookDialog from "./dialogPage/dialogOrder"; //查看

	// 方法的JS文件
	import { getOrderList} from "~/api/order";
	import orderFn from "./getOrderList";
	import orderStatistics from "~/components/orderStatistics"
	import settlementDetail from "./dialogPage/settlement-detail"
	// import settlementDetail2 from "./dialogPage/settlementDetail"
	import lastMonthSettlement from "~/pages/agent/settlement/components/lastMonthSettlement"
	//导出
	import {
		exportExcel
	} from "~/util/index";
	export default {
		head: {
			title: "我的结算"
		},
		name: "processed",
		components: {
			lookDialog,
			orderStatistics,
			settlementDetail,
			lastMonthSettlement
			// settlementDetail2
		},
		data() {
			return {
				checked:true,
				checked1:true,
				checked2:true,
				checked3:true,
				checked4:true,
				checked5:true,
				checked6:true,
				checked7:true,
				checked8:true,
				checked9:true,
				checked10:true,
				checked11: true,
				checked12: true,
				checked99: true,
				tableData: [],
				tableData2:[],
				loading: true,
				roleID: 1,
				//默认域名
				baseUrl: global.baseurl,

				// 分页
				tableSize: 10, //一页几条
				currentPage: 1, //目前在第几页
				pageSizes: [25, 50], //一页可以几条
				myInfo: {},
				total: 0,
				order_process: {},
				order_agent: {},
				showFilter: false, // 控制显示筛选条件
				showFilterCondition: false,
				conditionForm: {
					condition: []
				}, //筛选条件
				columns: [
					{
						label: '订单编号',
						id: 1,
						parameter: 'order_number'
					},
					{
						label: '专利类型',
						id: 2,
						parameter: 'type'
					},
					{
						label: '案件名称',
						id: 3,
						parameter: 'name'
					},
					{
						label: '联络人',
						id: 4,
						parameter: 'liaisons'
					},
					{
						label: '扣款情况',
						id: 5,
						parameter: 'deduction'
					},
					{
						label: '案件奖励',
						id: 6,
						parameter: 'reward'
					},
					{
						label: '结算金额',
						id: 7,
						parameter: 'settlements_price'
					},
					{
						label: '结算状态',
						id: 8,
						parameter: 'settlement_status'
					},
					{
						label: '结算类型',
						id: 9,
						parameter: 'settlements_name'
					},
					// {
					// 	label: '流程人员',
					// 	id: 5,
					// 	parameter: 'process_id'
					// },
					// {
					// 	label: '修改时间',
					// 	id: 10,
					// 	parameter: 'upDateTime'
					// },
					{
						label: '定稿时间',
						id: 11,
						parameter: 'createdTime'
					}
				],
				lastTime: 0,
				searchValue: '',
				upDateTime: [],
				createdTime: [],
				restaurants: [],
				restaurants2: [],
				formAgent: {},
				formProcess: {},
				paramsByOrder: {
					// status: '等待提交国知局,已提交国知局,等待答复,等待补正,已补正,已答复,受理,初审,实审,驳回,授权,撤案',
					// settlement: 1
				},
				settlementsPriceMoney: '',
				deductionMoney: '',
				rewardMoney: '',
				realMoney: ''

			};
		},
		async asyncData({
			$axios,
			store
		}) {
			let paramsByOrder = {
				// status: '等待提交国知局,已提交国知局,等待答复,等待补正,已补正,已答复,受理,初审,实审,驳回,授权,撤案',
				// settlement: 1
			}

			// if (store.state.user.role_id == 2) {
			// 	paramsByOrder.agent_id = store.state.user.id;
			// }
			return orderFn.getSettlementList($axios, store, paramsByOrder, 'fromProcessed')
		},
		mounted () {
		},
		created () {
			// if (this.$store.state.user.role_id == 2) {
				// this.mergeTable()
			// }
		},
		computed: {
			checked_arr() {
				let arr = [this.checked1, this.checked2, this.checked3, this.checked4, this.checked5, this.checked6, this.checked7, this.checked8, this.checked9, this.checked10, this.checked11, this.checked12]
				return arr
			}
		},
		methods: {
			lastMonthSettlement () {
				this.$refs['lastMonthSettlement'].show()
			},
			setttlementDetail(row) {
				this.$refs['settlement-detail'].showOn(row.id)
			},
			selectAll(val) {
				if (val) {
							this.checked1 = true;
							this.checked2 = true;
							this.checked3 = true;
							this.checked4 = true;
							this.checked5 = true;
							this.checked6 = true;
							this.checked7 = true;
							this.checked8 = true;
							this.checked9 = true;
							this.checked10 = true;
							this.checked11 = true;
							this.checked12 = true;
						} else {
							this.checked1 = false;
							this.checked2 = false;
							this.checked3 = false;
							this.checked4 = false;
							this.checked5 = false;
							this.checked6 = false;
							this.checked7 = false;
							this.checked8 = false;
							this.checked9 = false;
							this.checked10 = false;
							this.checked11 = false;
							this.checked12 = false;
						}
			},
			//选择一页几条
			async handleSizeChange(size) {
				this.paramsByOrder.perPage = size
				this.paramsByOrder.page = 1
				// if (this.$store.state.user.role_id == 2) {
				// 	this.paramsByOrder.agent_id = this.$store.state.user.id;
				// }
				let data = await orderFn.getSettlementList(this.$axios, this.$store, this.paramsByOrder, 'fromProcessed');
				for (let key in data) {
					this[key] = data[key];
				}
			},
			//选择第几页
			async handleCurrentChange(val) {
				this.currentPage = val;
				// let parms = this.paramsByOrder

				this.paramsByOrder.page  = val
				// if (this.$store.state.user.role_id == 2) {
				// 	this.paramsByOrder.agent_id = this.$store.state.user.id;
				// }
				let data = await orderFn.getSettlementList(this.$axios, this.$store, this.paramsByOrder, 'fromProcessed');
				for (let key in data) {
					this[key] = data[key]
				}
			},

			//查看
			lookOrder(row) {
				if (this.roleID !== 2) {
					if(window.getSelection().toString() === ''){
						this.order_process = row.process;
						this.order_agent = row.agent || {};
						this.$refs.orderDialog.showDialog(row.id, "已结单");
					}
				}
			},

			editOrder() {},
			//获取表格数据
			async getData(pQuery) {
				this.roleID = this.$store.state.user.role_id;
				// this.paramsByOrder.status = '等待提交国知局,已提交国知局,等待答复,等待补正,已补正,已答复,受理,初审,实审,驳回,授权,撤案'

				// if (this.$store.state.user.role_id == 2) {
				// 	this.paramsByOrder.agent_id = this.$store.state.user.id;
				// }
				if (pQuery) {
					this.paramsByOrder = {}
					this.paramsByOrder.created_start_time = pQuery.created_start_time
					this.paramsByOrder.created_end_time = pQuery.created_end_time
				}
				let data = await orderFn.getSettlementList(this.$axios, this.$store, this.paramsByOrder, 'fromProcessed');
				for (let key in data) {
					this[key] = data[key]
				}
			},
			//删除
			delOrder(val) {
				var that = this;
				let paramsByOrder = {
					status: "已结单"
				};
				orderFn.delOrderByJS(this.$axios, val.id, paramsByOrder, that);
			},
			exportExcel(name, type) {
				let parms = {}
				if(this.$store.state.user.role_id==4){
					parms.process_id=this.$store.state.user.id
				}
				getOrderList(this.$axios, parms)
				.then(res=>{
					if (res.data.code == 200) {
						this.tableData2 = res.data.data;
						exportExcel(this, this.$store.state.user.role_id == 2?"我的结算":"已撤案", type, "#orderTbTemp");
					}
				})
			},

			getYMD(val) {
				// timeDay = val.replace(/-/g, "/");
			},

    	//输入抬头模糊匹配
			querySearch(queryString, cb) {
				let that = this;
				let restaurants = this.restaurants;
				let results = [];
				if (restaurants.length > 0) {
					results = queryString ? restaurants.filter(that.createFilter(queryString)) : restaurants;
				}
				// 调用 callback 返回建议列表的数据
				cb(results);
			},
			//匹配
			createFilter(queryString) {
				return restaurant => {
					return (
						restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) >= 0
					);
				};
			},
			//模糊匹配赋值
			handleSelect(item) {
				this.formAgent.id = item.id;
				this.$refs['conditionForm'].clearValidate();
			},

		  async search() {
				this.currentPage = 1

				for(var i = 0; i < this.conditionForm.condition.length; i++) {
					let a = this.conditionForm.condition[i].parameter
					if (this.conditionForm.condition[i].parameter === 'upDateTime') {
						this.paramsByOrder.start_time = this.upDateTime[0]
						this.paramsByOrder.end_time = this.upDateTime[1]
					}
					if (this.conditionForm.condition[i].parameter === 'createdTime') {
						this.paramsByOrder.created_start_time = this.createdTime[0]
						this.paramsByOrder.created_end_time = this.createdTime[1]
					}
					this.paramsByOrder[a] = this.conditionForm.condition[i].value
				}
				// if (this.$store.state.user.role_id == 2) {
				// 	this.paramsByOrder.agent_id = this.$store.state.user.id;
				// }
				if(this.paramsByOrder.process_id === '') {
					this.paramsByOrder.process_id = this.formProcess.id
				}

				let processNames = []
				for(let z = 0; z < this.restaurants2.length; z++) {
					processNames.push(this.restaurants2[z].name)
				}
				let processV = processNames.indexOf(this.formProcess.name)
				processV === -1 ? this.paramsByOrder. process_id = this.formProcess.name: this.paramsByOrder. process_id = this.restaurants2[processV].id


				// 处理分页数据
				delete this.paramsByOrder.page

				// 处理排序状态
				delete this.paramsByOrder.sort_str
				delete this.paramsByOrder.sort_order
				this.$refs['orderTb'].clearSort()

				let data = await orderFn.getSettlementList(this.$axios, this.$store, this.paramsByOrder, 'fromProcessed');
				for (let key in data) {
					this[key] = data[key];
				}
				this.showFilter = false
			},

			// 添加条件筛选
			addFilterCondition (item) {
				let filterItem = {
					value: '',
					label: item.label,
					parameter: item.parameter,
					key: Date.now()
				}

				if (this.conditionForm.condition.length > 0) {
					let conditionlabels = []
					for(let i = 0; i < this.conditionForm.condition.length; i++) {
						conditionlabels.push(this.conditionForm.condition[i].label)
					}
					let Check = conditionlabels.indexOf(item.label)
					Check == -1 ? this.conditionForm.condition.push(filterItem) : this.$message.error('请勿重复添加')
				} else {
					this.conditionForm.condition.push(filterItem)
				}

				this.showFilterCondition = false;
			},

			resetForm(formName) {
				this.$refs[formName].resetFields()
				this.$refs['orderTb'].clearSort()
				this.conditionForm.condition.forEach(v => {
					if (v.value) {
						v.value = null
					}
				});
				this.upDateTime = []
				this.createdTime = []
				this.paramsByOrder = {
					// status: '等待提交国知局,已提交国知局,等待答复,等待补正,已补正,已答复,受理,初审,实审,驳回,授权,撤案',
					// settlement: 1
				}
				this.$nextTick(() => {
					this.$refs[formName].clearValidate()
				})
				// this.getData()
				// this.showFilter = false
				// this.showFilterCondition = false
			},

			submitsearch(formName) {
				let that = this
				this.$refs[formName].validate((valid, prop) => {
				// this.$refs[formName].clearValidate();
					let props = []
					for (let k in prop) {
						props.push(prop[k][0].field)
						if (prop[k][0].message = '修改时间不能为空') {
							if (that.upDateTime) {
								if (that.upDateTime.length > 0) {
									that.$refs[formName].clearValidate([prop[k][0].field])
									// that.search()
									let timeIndex = props.indexOf('修改时间不能为空')
									props.splice(timeIndex, 1)
								}
							} else {
								return false
							}
						}
						if (prop[k][0].message = '定稿时间不能为空') {
							if (that.createdTime) {
								if (that.createdTime.length > 0) {
									that.$refs[formName].clearValidate([prop[k][0].field])
									// that.search()
									let timeIndex = props.indexOf('定稿时间不能为空')
									props.splice(timeIndex, 1)
								}
							} else {
								return false
							}
						}
					}
					if (props.length) {
						that.$refs[formName].validateField(props, (valid2) => {
							if(valid2) {
								return false;
							} else {
								that.search()
							}
						})
					} else {
						that.search()
					}
				})
			},
			removeDomain(item) {
				this.showFilter = true
				delete this.paramsByOrder[item.parameter]
				let index = this.conditionForm.condition.indexOf(item)
				if (index !== -1) {
					this.conditionForm.condition.splice(index, 1)
				}
				if (item.label === '修改时间') {
					this.upDateTime = []
					delete this.paramsByOrder.start_time
					delete this.paramsByOrder.end_time
      			}
				if (item.label === '定稿时间') {
					this.createdTime = []
					delete this.paramsByOrder.created_start_time
					delete this.paramsByOrder.created_end_time
				}
				this.search()
			},
			changInput () {
      	this.$refs['conditionForm'].clearValidate();
			},
			// 表格排序
			tableSortChange(column) {
				if (column.order === 'descending') {
					this.paramsByOrder.sort_str = column.prop
					this.paramsByOrder.sort_order = 'desc'
				} else if (column.order === 'ascending'){
					this.paramsByOrder.sort_str = column.prop
					this.paramsByOrder.sort_order = 'asc'
				} else {
					delete this.paramsByOrder.sort_str
					delete this.paramsByOrder.sort_order
				}
				// if (column.prop =='liaisons' ||
				// 		column.prop == 'actualAmount' ||
				// 		column.prop == 'settlement.settlement_type.name' ||
				// 		column.prop == 'settlement.settlement_type.settlements_price' ||
				// 		column.prop == 'settlement.reward' ||
				// 		column.prop == 'settlement.status' ||
				// 		column.prop == 'chargeType' ||
				// 		column.prop == 'deductionsSituation'
				// 		) {
				// 	return
				// }
				this.loading = true;
				// if (this.$store.state.user.role_id == 2) {
				// 	this.paramsByOrder.agent_id = this.$store.state.user.id;
				// }
				this.$axios.get('/api/settlement', {
					params: this.paramsByOrder
				})
				.then(res => {
					this.loading = false;
					this.tableData = res.data.data;
					this.pageSize = res.data.page.per_page;
					this.tableSize = res.data.page.per_page;
					this.tableEnd = res.data.page.per_page;
					this.total = res.data.page.total;

					// this.realMoneyTotal = res.data.money_total.realMoney
					// this.settlementsPriceMoney = res.data.money_total.settlements_price_money
					// this.deductionMoney = res.data.money_total.deduction_money
					// this.rewardMoney = res.data.money_total.reward_money
				})
			},
			//  表格末尾合计
			getSummaries (param) {
				// console.log(param)
				const { columns, data } = param
				const sums = []
				columns.forEach((column, index) => {
          if (index === 1) {
            sums[index] = '结算总和(含税)';
            return;
          }
					if (column.label === '实际金额') {
						sums[index] = this.realMoneyTotal
					}
					if (column.label === '扣款情况') {
						sums[index] = this.deductionMoney
					}
					if (column.label === '结算金额') {
						sums[index] = this.settlementsPriceMoney
					}
					if (column.label === '案件奖励') {
						sums[index] = this.rewardMoney
					}
					// sums[index] = '';
				})

				return sums
			}
		},
		beforeUpdate() {
			this.$nextTick(() => {
				if(this.$refs.orderTb){
					this.$refs.orderTb.doLayout();
				}
			});
		},
		watch: {
			checked_arr: {
				handler: function(val) {
					if (val.some(v => v == false)) {
					this.checked = false
					} else {
					this.checked = true
					}
					if (val.every(v => v == false)) {
						this.checked99 = false
					} else {
						this.checked99 = true
					}
				},
				deep: true
			}
			// 'checked'(val, Oval) {
			// 		if (val != Oval) {
			// 			if (val) {
			// 				this.checked1 = true;
			// 				this.checked2 = true;
			// 				this.checked3 = true;
			// 				this.checked4 = true;
			// 				this.checked5 = true;
			// 				this.checked6 = true;
			// 				this.checked7 = true;
			// 				this.checked8 = true;
			// 				this.checked9 = true;
			// 				this.checked10 = true;
			// 				this.checked11 = true;
			// 				this.checked12 = true;
			// 			} else {
			// 				this.checked1 = false;
			// 				this.checked2 = false;
			// 				this.checked3 = false;
			// 				this.checked4 = false;
			// 				this.checked5 = false;
			// 				this.checked6 = false;
			// 				this.checked7 = false;
			// 				this.checked8 = false;
			// 				this.checked9 = false;
			// 				this.checked10 = false;
			// 				this.checked11 = false;
			// 				this.checked12 = false;
			// 			}
			// 		}
			// 	}
		},
	};
</script>

<style  lang="less">
	.auditor-main {
    height: 100%; //撑满表格
    .el-table {
      width: 99.9% !important;
    }
  }
	.pagination {
		margin-top: 30px;
	}
	.el-main .ivu-poptip .ivu-poptip-popper .ivu-poptip-content .ivu-poptip-inner{
    min-width: 450px ;
    // height: 300px;
    overflow-y:scroll;
  }
  .el-dropdown {
    font-size: 12px;
    margin: 0 5px;
    color: #2d8cf0;
  }
  .el-main .poptip-condition .ivu-poptip-popper .ivu-poptip-content .ivu-poptip-inner {
    min-width: 180px ;
	}
	.poptip-condition {
		display: block;
		margin-top: 10px;
		.poptip-condition-item {
			line-height: 25px;
			cursor:pointer;
		}
		.poptip-condition-add {
			font-size: 14px;
		}
	}

	.demo-dynamic {
		padding-left: 10px;
		.el-form-item {
			margin-bottom: 12px;
		}
		.el-input {
			width: 240px;
		}
		.el-date-editor {
			width: 240px;
		}
		.el-button {
			padding: 9px 15px;
			vertical-align: baseline;
		}
		.el-form-item__error {
			padding-top: 0 ;
		}

		.el-main .ivu-poptip .ivu-poptip-popper .ivu-poptip-content .ivu-poptip-inner{
			min-width: 450px ;
			height: 300px;
			overflow-y:scroll;
		}
		.el-dropdown {
			font-size: 12px;
			margin: 0 5px;
			color: #2d8cf0;
		}

	}

	.btns {
		margin-top: 10px;
	}
	.down-execel {
		display: block;
		height: 40px;
		line-height: 40px;
		color: #333333;
		font-size: 14px;
		margin-right: 20px;
		float: right;
	}
	.font_green {
		color: #67C23A;
		font-weight: 700;
	}
	.font_red {
		color: #F56C6C;
		font-weight: 700;
	}
	.font_yellow {
		color: #E6A23C;
		font-weight: 700;
	}
	.el-table__footer {
		colgroup {
			// col:nth-child(1) {
			// 	width: 120px !important

			// }
			// col:nth-child(2) {
			// 	width: 140px !important;
			// }
		}
		.has-gutter {

			.font_success {
				color: #67C23A;
				font-weight: 700;
			}
			.font_warning {
				color: #E6A23C;
				font-weight: 700;
			}
			.font_danger {
				color: #F56C6C;
				font-weight: 700;
			}
			tr {
				td:nth-child(1) {
					border-right: 0;
					// position: relative;
					div {
						// position: absolute;
						// top: 0;
						// width: 200px;
						// height: 32px;
					}
				}
			}
		}
	}

</style>
